<!DOCTYPE html>
<html>
<head>
    <style>
        #box {
            width: 100px;
            height: 100px;
            background: blue;
        }
    </style>
</head>
<body>
    <div id="box"></div>

    <script>
        const box = document.querySelector('#box');

        const resizeObserver = new ResizeObserver(entries => {
            console.log('当前大小', entries)
        });
        resizeObserver.observe(box);

        setTimeout(() => {
            box.style.width = '200px';
        }, 3000);
    </script>
</body>
</html>
